<?php
define('SCR','view');

require_once('global.php');
require_once(R_P . 'require/init.php');

$page = intval($page);

!$tid && throwError('notid');
!$cid && throwError('nocid');

require_once(R_P.'require/class_cms.php');
$cms	=	new Cms();
$cont	=	new Cont();
$mid	=	$catedb[$cid]['mid'];
$view	=	array();
$cont->url = $contentUrl;
$view	=	$cont->getone($cid,$tid,$page);
if ($view['ifprivate'] && $view['publisher'] != $login_name) {
	showAlert('对不起，此内容为私有内容，只有上传者自己可以浏览');
}

require_once(R_P . 'require/class_resource.php');
$res = new Resource();
$resList = $res->getOne($tid, 0, $page);
$count = $view['resnum'];
$pagesize = !$very['content_pagesize'] ? 25 : $very['content_pagesize'];
$numofpage = ceil($count/$pagesize);

if ($_GET['viewtype'] == '0') {
	Cookie('viewtype', '0');
	$viewtype = 0;
} elseif (GetCookie('viewtype') == '1' || $_GET['viewtype'] == '1') {
	Cookie('viewtype', '1');
 	$viewtype = 1;
} else {
	$viewtype = 0; //默认用Table方式
}
$pages = numofpage($count, $page, $numofpage, "view.php?tid=$tid&cid=$cid&viewtype=" . $viewtype . "&");
unset($_GET,$_POST,$_REQUEST);
//print_r($resList);exit;

if(!function_exists('adminmsg'))
{
	if(!GetCookie("$tid"))	{
		$db->update("UPDATE cms_contentindex SET hits=hits+1 WHERE tid='$tid' AND cid='$cid'");
		$val = rand(1,10);
		$ck_time = $timestamp + 3600;
		Cookie("$tid","$val",$ck_time);
	}
}

start($very['charset']);
require Template();
footer();
?>